home *** CD-ROM | disk | FTP | other *** search
/ The Programmer Disk / The Programmer Disk (Microforum).iso / xpro / qb2 / pro20 / scrrstr.asm < prev    next >
Encoding:
Assembly Source File  |  1988-12-21  |  2.1 KB  |  74 lines

  1. ; Passing Parameters to Assembly: STRING
  2. ; --------------------------------------
  3. ;
  4. ; This procedure sets the appropriate video segment based on the video
  5. ; adapter installed, then puts the contents of a string that is passed from
  6. ; QB onto the screen.
  7. ;
  8.  
  9. .model  medium
  10.  
  11. .code
  12.  
  13.         public  ScrRstr
  14. ScrRstr proc    far
  15.  
  16.         push    bp          ;
  17.         push    ds          ;
  18.         push    es          ;Save the registers for QuickBASIC
  19.         push    si          ;
  20.         push    di          ;
  21.  
  22.         mov     bp,sp       ;use BP as stack index
  23.  
  24.         mov     bx,[bp+6]   ;Get the address of the BASIC string descriptor
  25.         mov     cx,[bx]     ;put the length of the passed string in CX
  26.         mov     si,[bx+2]   ;put the offset of the passed string is SI
  27.  
  28. Get_Adapter:
  29.  
  30.         mov     bx,0        ;
  31.         mov     es,bx       ;go to low memory
  32.         mov     ax,es:[449h]  ;put the video mode byte into AX
  33.  
  34.         cmp     al,3        ;
  35.         jle      CGA        ;if mode <= 3 then it is CGA text mode
  36.         cmp     al,7        ;
  37.         jz      Hercules    ;elseif mode = 7 then it is Hercules text mode
  38.         jmp finish          ;elseif neither, exit
  39.  
  40.  CGA:
  41.  
  42.         mov     bx,0b800h   ;put CGA text video segment in BX
  43.         jmp Set_Vid_Seg     ;jump over Hercules section
  44.  
  45. Hercules:
  46.  
  47.         mov     bx,0b000h   ;put Hercules text video segment in BX
  48.  
  49. Set_Vid_Seg:
  50.  
  51.         mov     es,bx       ;put the text video segment in ES
  52.         mov     di,0        ;
  53.  
  54.         ;MOVSB is an instruction that MOVes a String Byte from DS:SI to ES:DI
  55.         ;the following repeats the MOVSB instruction the number of times
  56.         ;in CX (CX contains the length of the string passed from QB)
  57.  
  58.         rep     movsb
  59.  
  60. finish:                     ;wrap it up and restore QB's registers
  61.  
  62.         pop     di
  63.         pop     si
  64.         pop     es
  65.         pop     ds
  66.         pop     bp
  67.  
  68.         ret     2           ;return and pop 2 bytes off of the stack
  69.                             ;(1 integer parameter, 2 bytes, passed from QB)
  70.  
  71. ScrRstr endp
  72.  
  73. END
  74.